home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / test / lib / stkjump.c < prev    next >
C/C++ Source or Header  |  1992-11-23  |  522b  |  46 lines

  1.  
  2. /*
  3.  *  TEST/STKJUMP.C
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <setjmp.h>
  9.  
  10. jmp_buf x;
  11.  
  12. extern long _stack_base;
  13.  
  14. myexit()
  15. {
  16.     longjmp(x, 2);
  17. }
  18.  
  19. main(ac, av)
  20. char *av[];
  21. {
  22.     int r;
  23.  
  24.     onbreak(myexit);
  25.  
  26.     if (r = setjmp(x)) {
  27.     Execute("avail", 0, 0);
  28.     printf("exit code %d\n", r);
  29.     exit(10);
  30.     }
  31.     Execute("avail", 0, 0);
  32.     subroutine(atoi(av[1]));
  33.     return(0);
  34. }
  35.  
  36. subroutine(n)
  37. {
  38.     char buf[256];
  39.  
  40.     if (n == 0)
  41.     return;
  42.     printf("Base = %08lx\n", _stack_base);
  43.     subroutine(n - 1);
  44. }
  45.  
  46.